﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using HYView;

namespace Model
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	internal class CmdCableTrayAlignment : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			this.m_uiApp = cmdData.Application;
			Autodesk.Revit.DB.View activeView = this.m_uiApp.ActiveUIDocument.Document.ActiveView;
			if ((int)activeView.ViewType != 1 && (int)activeView.ViewType != 2 && (int)activeView.ViewType != 3 && (int)activeView.ViewType != 117)
			{
				Result result = SwitchView.SetUsableView((CmdViewType)99, cmdData);
				if (result != Result.Succeeded)
				{
					return result;
				}
			}
			new CableTrayAlignment(cmdData).Excute();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		protected UIApplication m_uiApp;
	}
}
